﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace text1
{
    public partial class login2 : Form
    {
        
        public login2()
        {
     
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            String username, password, repassword;
            username = textBox1.Text;
            password = textBox2.Text;
            repassword = textBox3.Text;
            if (password == repassword)//两次输入的密码一致
            {
                string myConn = @"server=LAPTOP-NHBSREVG;database=LOGIN;uid=sa;pwd=990823";
                SqlConnection sqlConnection = new SqlConnection(myConn);  //实例化连接对象
                sqlConnection.Open();

                String sql = "INSERT INTO PEOPLE(SID,SKEY) VALUES('" + username + "','" + password + "')";//SQL语句向表中写入数据
                SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
                sqlCommand.ExecuteNonQuery();
                MessageBox.Show("注册成功");

            }
            else
            {
                MessageBox.Show("密码不一致");
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            login nf = new login();
            nf.ShowDialog();
            this.Dispose();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            textBox2.PasswordChar = '*';
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            textBox3.PasswordChar = '*';
        }





        private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
  
        }

        private void login2_Load(object sender, EventArgs e)
        {

        }
    }
}
